﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace ChurchDiary.Common
{
    public static class Current
    {

        public static void SetSession<T>(string Sessionid, T value)
        {
            HttpContext.Current.Session[Sessionid] = value;
        }
        public static T GetSession<T>(string Sessionid)
        {
            var val = default(T);
            var session = HttpContext.Current.Session;

            if (session[Sessionid] != null)
            {
                val = (T)session[Sessionid];
            }
            return (T)val;
        }
        public static string SessionID
        {
            get
            {
                return HttpContext.Current.Session.SessionID;
            }
        }
        public static string Name
        {
            get
            {
                return GetSession<string>("Name").ToString();
            }
            set
            {
                SetSession<string>("Name", value);
            }
        }
        public static string Image
        {
            get
            {
                return GetSession<string>("Image").ToString();
            }
            set
            {
                SetSession<string>("Image", value);
            }
        }
        public static Guid ChurchId
        {
            get
            {
                return GetSession<Guid>("ChurchId");
            }
            set
            {
                SetSession<Guid>("ChurchId", value);
            }
        }
        public static Guid LanaguageId
        {
            get
            {
                return GetSession<Guid>("LanaguageId");
            }
            set
            {
                SetSession<Guid>("LanaguageId", value);
            }
        }
        public static Guid Userid
        {
            get
            {
                return GetSession<Guid>("Userid");
            }
            set
            {
                SetSession<Guid>("Userid", value);
            }
        }
        public static DateTime LastLogin
        {
            get
            {
                return GetSession<DateTime>("LastLogin");
            }
            set
            {
                SetSession<DateTime>("LastLogin", value);
            }
        }
        public static bool IsSuperAdmin
        {
            get
            {
                return GetSession<bool>("IsSuperAdmin");
            }
            set
            {
                SetSession<bool>("IsSuperAdmin", value);
            }
        }
        public static string UserImage
        {
            get
            {
                return GetSession<string>("UserImage");
            }
            set
            {
                SetSession<string>("UserImage", value);
            }
        }
        public static string CoverImage
        {
            get
            {
                return GetSession<string>("CoverImage");
            }
            set
            {
                SetSession<string>("CoverImage", value);
            }
        }
    }
}
